package com.jialanmo.zhihudaily.ui.main;

import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.TextView;

import com.jialanmo.helper.recyclerview.BaseAdapter;
import com.jialanmo.helper.OnItemClickListener;
import com.jialanmo.helper.recyclerview.ViewHolder;
import com.jialanmo.zhihudaily.R;
import com.jialanmo.zhihudaily.data.model.Themes;

import java.util.ArrayList;
import java.util.List;

public final class DrawerAdapter extends BaseAdapter<Themes.Theme> {

    private final List<Themes.Theme> mData = new ArrayList<>();

    private final OnItemClickListener mOnItemClickListner;

    public DrawerAdapter(OnItemClickListener onItemClickListner) {
        mOnItemClickListner = onItemClickListner;
    }

    @Override
    public List<Themes.Theme> getData() {
        return mData;
    }

    @Override
    public int getItemCount() {
        return mData.size();
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.activity_main_drawerlayout_theme_recyclerview_item, parent, false), this, mOnItemClickListner);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        ((TextView) holder.itemView).setText(mData.get(position).getName());
    }
}
